package gui;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import midlet.MidletCielsa;
import rms.SesionRMS;
import util.CommandBuilder;

/**
 *
 * @author Dikas
 */
public class FrmConfirmacionSalida extends Form implements CommandListener {

    private MidletCielsa midlet;
    private Displayable previousDisplayable;
    private Command cmdCancelar;
    private Command cmdOk;

    public FrmConfirmacionSalida(MidletCielsa midlet, Displayable previousDisplayable) {
        super("Confirmar");
        this.midlet = midlet;
        this.previousDisplayable = previousDisplayable;
        cmdCancelar = CommandBuilder.getCancelar();
        cmdOk = CommandBuilder.getOk();
        addCommand(cmdCancelar);
        addCommand(cmdOk);
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        if (c == cmdCancelar) {
            midlet.setDisplay(previousDisplayable);
        } else if (c == cmdOk) {
            SesionRMS rms = new SesionRMS();
            rms.setId(0);
            rms.setNombre("");
            rms.setEmail("");
            rms.setApellidoMaterno("");
            rms.setApellidoPaterno("");
            rms.setSID("");;
            FrmLogin fl = new FrmLogin(midlet);            
            midlet.setDisplay(fl);
        }
    }
}
